/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package PresentationTier;

import PresentationTier.Pesquisa.GUIIBGEPesquisar;
import PresentationTier.Pesquisa.GUIContratadoPesquisar;
import BusinessTier.ContratadoBUS;
import BusinessTier.IBGEBUS;
import EntitiesTier.ClContratado;
import EntitiesTier.ClIBGE;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.beans.PropertyVetoException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author douglas
 */
public class GUICadContratado extends javax.swing.JInternalFrame 
{
    private ClContratado cl;
    private ClIBGE clIBGE;

    private String state;
    /**
     * Creates new form GUICadContratado
     */
    public GUICadContratado() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        pnNav = new javax.swing.JPanel();
        btnNovo = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();
        btnExcluir = new javax.swing.JButton();
        btnGravar = new javax.swing.JButton();
        btnSair = new javax.swing.JButton();
        btnPesq = new javax.swing.JButton();
        btnEdit = new javax.swing.JButton();
        pnEnd = new javax.swing.JPanel();
        lvlEnd = new javax.swing.JLabel();
        lblNum = new javax.swing.JLabel();
        edtEnd = new javax.swing.JTextField();
        edtNum = new javax.swing.JTextField();
        lblBairro = new javax.swing.JLabel();
        edtBairro = new javax.swing.JTextField();
        lblCompl = new javax.swing.JLabel();
        edtCompl = new javax.swing.JTextField();
        lvlCidade = new javax.swing.JLabel();
        edtCidade = new javax.swing.JTextField();
        lblUF = new javax.swing.JLabel();
        edtUF = new javax.swing.JTextField();
        lblCep = new javax.swing.JLabel();
        edtCep = new javax.swing.JTextField();
        btnIBGE = new javax.swing.JButton();
        edtIBGE = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        pnContato = new javax.swing.JPanel();
        edtCPFRESP = new javax.swing.JTextField();
        edtRGRESP = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        lblCont = new javax.swing.JLabel();
        lblFon1 = new javax.swing.JLabel();
        lblFon2 = new javax.swing.JLabel();
        lblFax = new javax.swing.JLabel();
        edtFone1 = new javax.swing.JTextField();
        edtContato = new javax.swing.JTextField();
        edtResp = new javax.swing.JTextField();
        edtEmail = new javax.swing.JTextField();
        lblEmail = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        edtCPF = new javax.swing.JTextField();
        lblApl = new javax.swing.JLabel();
        lblNm = new javax.swing.JLabel();
        edtApelido = new javax.swing.JTextField();
        edtNome = new javax.swing.JTextField();
        jCheckBox1 = new javax.swing.JCheckBox();
        edtRG = new javax.swing.JTextField();
        lblRG = new javax.swing.JLabel();
        lblCPF = new javax.swing.JLabel();
        lblCodCont = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        rbFisico = new javax.swing.JRadioButton();
        rbJuridico = new javax.swing.JRadioButton();

        setClosable(true);
        setTitle("SGC - Cadastro de Contratados");
        setMinimumSize(new java.awt.Dimension(700, 500));
        setPreferredSize(new java.awt.Dimension(700, 500));

        pnNav.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        pnNav.setPreferredSize(new java.awt.Dimension(690, 65));

        btnNovo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/add.png"))); // NOI18N
        btnNovo.setText("Novo");
        btnNovo.setDisplayedMnemonicIndex(1);
        btnNovo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnNovo.setMaximumSize(new java.awt.Dimension(50, 50));
        btnNovo.setMinimumSize(new java.awt.Dimension(50, 50));
        btnNovo.setPreferredSize(new java.awt.Dimension(50, 50));
        btnNovo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnNovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNovoActionPerformed(evt);
            }
        });

        btnCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/cancel.png"))); // NOI18N
        btnCancelar.setText("Cancelar");
        btnCancelar.setEnabled(false);
        btnCancelar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnCancelar.setMaximumSize(new java.awt.Dimension(75, 60));
        btnCancelar.setMinimumSize(new java.awt.Dimension(75, 60));
        btnCancelar.setPreferredSize(new java.awt.Dimension(75, 60));
        btnCancelar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        btnExcluir.setIcon(new javax.swing.JLabel() {
            public javax.swing.Icon getIcon() {
                try {
                    return new javax.swing.ImageIcon(
                        new java.net.URL("file:/C:/Users/Douglas/Google Drive/FATEC/SGC/Icones/Excluir.gif")
                    );
                } catch (java.net.MalformedURLException e) {
                }
                return null;
            }
        }.getIcon());
        btnExcluir.setEnabled(false);
        btnExcluir.setFocusPainted(false);
        btnExcluir.setFocusable(false);
        btnExcluir.setPreferredSize(new java.awt.Dimension(100, 40));
        btnExcluir.setRequestFocusEnabled(false);
        btnExcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExcluirActionPerformed(evt);
            }
        });

        btnGravar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/Gravar.png"))); // NOI18N
        btnGravar.setText("Gravar");
        btnGravar.setEnabled(false);
        btnGravar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnGravar.setPreferredSize(new java.awt.Dimension(100, 40));
        btnGravar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnGravar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGravarActionPerformed(evt);
            }
        });

        btnSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/Exit.png"))); // NOI18N
        btnSair.setText("Sair");
        btnSair.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnSair.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSairActionPerformed(evt);
            }
        });

        btnPesq.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/pesquisar.png"))); // NOI18N
        btnPesq.setText("Buscar");
        btnPesq.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnPesq.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnPesq.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPesqActionPerformed(evt);
            }
        });

        btnEdit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/edit.gif"))); // NOI18N
        btnEdit.setText("Editar");
        btnEdit.setEnabled(false);
        btnEdit.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnEdit.setPreferredSize(new java.awt.Dimension(100, 40));
        btnEdit.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnEdit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnNavLayout = new javax.swing.GroupLayout(pnNav);
        pnNav.setLayout(pnNavLayout);
        pnNavLayout.setHorizontalGroup(
            pnNavLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnNavLayout.createSequentialGroup()
                .addGap(67, 67, 67)
                .addComponent(btnNovo, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnGravar, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnEdit, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnPesq, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnSair, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 63, Short.MAX_VALUE)
                .addComponent(btnExcluir, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(20, 20, 20))
        );
        pnNavLayout.setVerticalGroup(
            pnNavLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnNavLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnNavLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(btnPesq, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnEdit, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnGravar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnNovo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnExcluir, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnCancelar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnSair, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(21, Short.MAX_VALUE))
        );

        pnEnd.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        lvlEnd.setText("Endereço .:");

        lblNum.setText("nº .:");

        edtEnd.setEditable(false);

        edtNum.setEditable(false);

        lblBairro.setText("Bairro .:");

        edtBairro.setEditable(false);

        lblCompl.setText("Complemento .:");

        edtCompl.setEditable(false);

        lvlCidade.setText("Cidade .:");

        edtCidade.setEditable(false);

        lblUF.setText("UF .:");

        edtUF.setEditable(false);

        lblCep.setText("CEP .:");

        edtCep.setEditable(false);

        btnIBGE.setText("Sel. IBGE");
        btnIBGE.setEnabled(false);
        btnIBGE.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnIBGEActionPerformed(evt);
            }
        });

        jLabel1.setText("IBGE .:");

        javax.swing.GroupLayout pnEndLayout = new javax.swing.GroupLayout(pnEnd);
        pnEnd.setLayout(pnEndLayout);
        pnEndLayout.setHorizontalGroup(
            pnEndLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnEndLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnEndLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnEndLayout.createSequentialGroup()
                        .addComponent(lvlEnd)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(edtEnd)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblNum)
                        .addGap(9, 9, 9)
                        .addComponent(edtNum, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnEndLayout.createSequentialGroup()
                        .addGroup(pnEndLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnEndLayout.createSequentialGroup()
                                .addComponent(lblCompl)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(edtCompl, javax.swing.GroupLayout.PREFERRED_SIZE, 314, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(40, 40, 40)
                                .addComponent(lblBairro))
                            .addGroup(pnEndLayout.createSequentialGroup()
                                .addComponent(lvlCidade)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(edtCidade, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lblUF)
                                .addGap(6, 6, 6)
                                .addComponent(edtUF, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lblCep)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(edtCep, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel1)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnEndLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnEndLayout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(edtIBGE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnIBGE))
                            .addComponent(edtBairro))))
                .addGap(21, 21, 21))
        );
        pnEndLayout.setVerticalGroup(
            pnEndLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnEndLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnEndLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lvlEnd)
                    .addComponent(edtEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblNum)
                    .addComponent(edtNum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnEndLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblBairro)
                    .addComponent(edtBairro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblCompl)
                    .addComponent(edtCompl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnEndLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lvlCidade)
                    .addComponent(edtCidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblUF)
                    .addComponent(edtUF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblCep)
                    .addComponent(edtCep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnIBGE)
                    .addComponent(edtIBGE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addContainerGap(13, Short.MAX_VALUE))
        );

        pnContato.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        edtCPFRESP.setEditable(false);

        edtRGRESP.setEditable(false);

        jLabel4.setText("RG Resp .:");

        lblCont.setText("CPF Resp .:");

        lblFon1.setText("Fone 1.:");

        lblFon2.setText("Contato .:");

        lblFax.setText("Responsavel .:");

        edtFone1.setEditable(false);

        edtContato.setEditable(false);

        edtResp.setEditable(false);

        edtEmail.setEditable(false);

        lblEmail.setText("Email .:");

        javax.swing.GroupLayout pnContatoLayout = new javax.swing.GroupLayout(pnContato);
        pnContato.setLayout(pnContatoLayout);
        pnContatoLayout.setHorizontalGroup(
            pnContatoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnContatoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnContatoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnContatoLayout.createSequentialGroup()
                        .addComponent(lblEmail)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(edtEmail))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnContatoLayout.createSequentialGroup()
                        .addComponent(lblFon1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(edtFone1, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblFon2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(edtContato, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblFax)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(edtResp))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnContatoLayout.createSequentialGroup()
                        .addComponent(lblCont, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(3, 3, 3)
                        .addComponent(edtCPFRESP)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(edtRGRESP, javax.swing.GroupLayout.PREFERRED_SIZE, 239, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(21, 21, 21))
        );
        pnContatoLayout.setVerticalGroup(
            pnContatoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnContatoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnContatoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblFon1)
                    .addComponent(lblFon2)
                    .addComponent(lblFax)
                    .addComponent(edtFone1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(edtContato, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(edtResp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnContatoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblCont)
                    .addComponent(edtCPFRESP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(edtRGRESP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnContatoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblEmail)
                    .addComponent(edtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        edtCPF.setEditable(false);

        lblApl.setText("Apelido .:");

        lblNm.setText("Nome .:");

        edtApelido.setEditable(false);
        edtApelido.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                edtApelidoActionPerformed(evt);
            }
        });

        edtNome.setEditable(false);

        jCheckBox1.setText("Tem IE?");

        edtRG.setEditable(false);

        lblRG.setText("RG .:");

        lblCPF.setText("CPF .:");

        lblCodCont.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblCodCont.setText("Código");

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Tipo"));
        jPanel2.setEnabled(false);

        buttonGroup1.add(rbFisico);
        rbFisico.setLabel("Físico");
        rbFisico.setName(""); // NOI18N
        rbFisico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbFisicoActionPerformed(evt);
            }
        });

        buttonGroup1.add(rbJuridico);
        rbJuridico.setLabel("Jurídico");
        rbJuridico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbJuridicoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(rbFisico)
                    .addComponent(rbJuridico))
                .addContainerGap(27, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(rbFisico)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(rbJuridico)
                .addGap(0, 8, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(lblCodCont, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(lblCPF, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(edtCPF, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCheckBox1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblRG, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(edtRG, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(lblApl, javax.swing.GroupLayout.DEFAULT_SIZE, 61, Short.MAX_VALUE)
                            .addComponent(lblNm, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(edtNome)
                            .addComponent(edtApelido))))
                .addGap(21, 21, 21))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblNm)
                    .addComponent(edtNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblApl)
                    .addComponent(edtApelido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblCPF)
                    .addComponent(edtCPF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jCheckBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblRG)
                    .addComponent(edtRG, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 0, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblCodCont, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pnEnd, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(pnContato, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(pnNav, javax.swing.GroupLayout.DEFAULT_SIZE, 684, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnContato, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnNav, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 14, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSairActionPerformed
        try {
            this.setClosed(true);
        } catch (PropertyVetoException ex) {
            Logger.getLogger(GUICadContratado.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btnSairActionPerformed

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        if (state == "EDIT")
            state = "BROWSE";
        else
            state = "";
        if (lblCodCont.getText() == "Código")
        {
            cl = null;
            Desativa();
        }
        else
        {
            Desativa();
            PreencheCampos();
        }
    }//GEN-LAST:event_btnCancelarActionPerformed

    private void edtApelidoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_edtApelidoActionPerformed

    }//GEN-LAST:event_edtApelidoActionPerformed

    private void btnNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNovoActionPerformed
        state = "INSERT";
        cl = new ClContratado();
        Ativa();
        LimpaCampos();
    }//GEN-LAST:event_btnNovoActionPerformed

    private void btnGravarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGravarActionPerformed
        
        ContratadoBUS bus = new ContratadoBUS();
        carregadadoscl();
        if (cl.getCODO_COD() == 0)
        {
            try {
                cl.setCODO_COD(bus.inserir(cl));
            } 
            catch (Exception ex) 
            {
                Logger.getLogger(GUICadContratado.class.getName()).log(Level.SEVERE, null, ex);
                state = "INSERT";
            }
            finally
            {
                state = "BROWSE";
                Desativa();
            }
        }
        else
        {
            try 
            {
                bus.atualizar(cl);
            } 
            catch (Exception ex) 
            {
                Logger.getLogger(GUILancAdic.class.getName()).log(Level.SEVERE, null, ex);
                state = "BROWSE";
            }
            finally
            {
                state = "BROWSE";
                Desativa();
            }
        }
    }//GEN-LAST:event_btnGravarActionPerformed

    private void btnPesqActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPesqActionPerformed
        Dimension tela =  Toolkit.getDefaultToolkit().getScreenSize();
          GUIContratadoPesquisar tPesqContratado = new GUIContratadoPesquisar(null, true);
          tPesqContratado.setLocation((tela.width- tPesqContratado.getSize().width)/2,
                       (tela.height- tPesqContratado.getSize().height)/2);
          tPesqContratado.setVisible(true);
        //Acrescentar essas linhas
        int idCliente = tPesqContratado.idcontratado;
       
        this.lblCodCont.setEnabled(true);
        this.lblCodCont.requestFocus();
        if (idCliente > 0)
        {
            //this.lblCodCont.setText(String.valueOf(idCliente));
            ContratadoBUS bus = new ContratadoBUS();
            try 
            {
                cl = bus.buscar(idCliente);
                PreencheCampos();
            } catch (Exception ex) {
                Logger.getLogger(GUICadContratado.class.getName()).log(Level.SEVERE, null, ex);
            }finally
            {
                state = "BROWSE";
            }
        }else
            state = "";
        tPesqContratado.setVisible(false);


    }//GEN-LAST:event_btnPesqActionPerformed

    private void btnExcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExcluirActionPerformed
        if(cl.getCODO_COD() > 0)
        {
            if (JOptionPane.showConfirmDialog(null,"Deseja Excluir o cliente " + cl.getCODO_RAZAO() +" ?") == JOptionPane.YES_OPTION)
            {
                ContratadoBUS bus = new ContratadoBUS();
                try 
                {
                    bus.excluir(cl.getCODO_COD());
                    LimpaCampos();
                } catch (Exception ex) {
                    Logger.getLogger(GUICadContratado.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    }//GEN-LAST:event_btnExcluirActionPerformed

    private void btnIBGEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIBGEActionPerformed
          Dimension tela =  Toolkit.getDefaultToolkit().getScreenSize();
          GUIIBGEPesquisar tPesqIBGE = new GUIIBGEPesquisar(null, true);
          tPesqIBGE.setLocation((tela.width- tPesqIBGE.getSize().width)/2,
                       (tela.height- tPesqIBGE.getSize().height)/2);
          tPesqIBGE.setVisible(true);
        //Acrescentar essas linhas
        edtIBGE.setText(tPesqIBGE.IBGE);
       
        this.lblCodCont.setEnabled(true);
        this.lblCodCont.requestFocus();
        if (edtIBGE.getText() != "")
        {
            PreencheIBGE();
        }
        tPesqIBGE.setVisible(false);
    }//GEN-LAST:event_btnIBGEActionPerformed

    private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditActionPerformed
        state = "EDIT";
        if( cl != null)
            Ativa();
    }//GEN-LAST:event_btnEditActionPerformed

    private void rbFisicoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbFisicoActionPerformed
        if (rbFisico.isSelected())
            Fisico();
        else
            Juridico();
    }//GEN-LAST:event_rbFisicoActionPerformed

    private void rbJuridicoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbJuridicoActionPerformed
        if (rbJuridico.isSelected())
            Juridico();
        else
            Fisico();
    }//GEN-LAST:event_rbJuridicoActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnEdit;
    private javax.swing.JButton btnExcluir;
    private javax.swing.JButton btnGravar;
    private javax.swing.JButton btnIBGE;
    private javax.swing.JButton btnNovo;
    private javax.swing.JButton btnPesq;
    private javax.swing.JButton btnSair;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JTextField edtApelido;
    private javax.swing.JTextField edtBairro;
    private javax.swing.JTextField edtCPF;
    private javax.swing.JTextField edtCPFRESP;
    private javax.swing.JTextField edtCep;
    private javax.swing.JTextField edtCidade;
    private javax.swing.JTextField edtCompl;
    private javax.swing.JTextField edtContato;
    private javax.swing.JTextField edtEmail;
    private javax.swing.JTextField edtEnd;
    private javax.swing.JTextField edtFone1;
    private javax.swing.JTextField edtIBGE;
    private javax.swing.JTextField edtNome;
    private javax.swing.JTextField edtNum;
    private javax.swing.JTextField edtRG;
    private javax.swing.JTextField edtRGRESP;
    private javax.swing.JTextField edtResp;
    private javax.swing.JTextField edtUF;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JLabel lblApl;
    private javax.swing.JLabel lblBairro;
    private javax.swing.JLabel lblCPF;
    private javax.swing.JLabel lblCep;
    private javax.swing.JLabel lblCodCont;
    private javax.swing.JLabel lblCompl;
    private javax.swing.JLabel lblCont;
    private javax.swing.JLabel lblEmail;
    private javax.swing.JLabel lblFax;
    private javax.swing.JLabel lblFon1;
    private javax.swing.JLabel lblFon2;
    private javax.swing.JLabel lblNm;
    private javax.swing.JLabel lblNum;
    private javax.swing.JLabel lblRG;
    private javax.swing.JLabel lblUF;
    private javax.swing.JLabel lvlCidade;
    private javax.swing.JLabel lvlEnd;
    private javax.swing.JPanel pnContato;
    private javax.swing.JPanel pnEnd;
    private javax.swing.JPanel pnNav;
    private javax.swing.JRadioButton rbFisico;
    private javax.swing.JRadioButton rbJuridico;
    // End of variables declaration//GEN-END:variables

    private void Juridico() 
    {
            rbFisico.setSelected(false);
            rbJuridico.setSelected(true);
            lblCPF.setText("CNPJ .:");            
            lblRG.setText("IE .:");
            lblNm.setText("Razão Social .:");
            lblApl.setText("Nome .:");
    }

    private void Fisico() 
    {
            rbFisico.setSelected(true);
            rbJuridico.setSelected(false);
            lblCPF.setText("CPF .:");            
            lblRG.setText("RG .:");   
            lblNm.setText("Nome .:");
            lblApl.setText("Apelido .:");
    }
    
    private void Ativa() 
    {
        edtNome.setEditable(true);
        edtApelido.setEditable(true);
        rbFisico.setEnabled(true);
        rbJuridico.setEnabled(true);
        edtRG.setEditable(true);
        edtCPF.setEditable(true);
        edtEnd.setEditable(true);
        edtNum.setEditable(true);
        edtCompl.setEditable(true);
        edtCidade.setEditable(true);
        edtUF.setEditable(true);
        edtCep.setEditable(true);
        edtFone1.setEditable(true);
        edtContato.setEditable(true);
        edtResp.setEditable(true);
        edtEmail.setEditable(true);
        edtCPFRESP.setEditable(true);
        edtRGRESP.setEditable(true);
        edtBairro.setEditable(true);
        edtIBGE.setEditable(true);
        btnIBGE.setEnabled(true);
        
        btnCancelar.setEnabled(true);
        btnGravar.setEnabled(true);
        btnEdit.setEnabled(false);
        btnNovo.setEnabled(false);
        btnPesq.setEnabled(false);
    }

    private void Desativa() 
    {
        edtNome.setEditable(false);
        edtApelido.setEditable(false);
        rbFisico.setEnabled(false);
        rbJuridico.setEnabled(false);
        edtRG.setEditable(false);
        edtCPF.setEditable(false);
        edtEnd.setEditable(false);
        edtNum.setEditable(false);
        edtCompl.setEditable(false);
        edtCidade.setEditable(false);
        edtUF.setEditable(false);
        edtCep.setEditable(false);
        edtFone1.setEditable(false);
        edtContato.setEditable(false);
        edtResp.setEditable(false);
        edtEmail.setEditable(false);
        edtCPFRESP.setEditable(false);
        edtRGRESP.setEditable(false);
        edtBairro.setEditable(false);
        edtIBGE.setEditable(false);
        btnIBGE.setEnabled(false);
        
        btnCancelar.setEnabled(false);
        btnGravar.setEnabled(false);
        if (state == "BROWSE")
            btnEdit.setEnabled(true);
        else
            btnEdit.setEnabled(false);
        btnNovo.setEnabled(true);
        btnPesq.setEnabled(true);
    }

    private void LimpaCampos() 
    {
        lblCodCont.setText("Código");
        edtNome.setText("");
        edtApelido.setText("");
        edtEnd.setText("");
        edtNum.setText("");
        edtCompl.setText("");
        edtCidade.setText("");
        edtUF.setText("");
        edtCep.setText("");
        edtFone1.setText("");
        edtContato.setText("");
        edtResp.setText("");
        edtEmail.setText("");
        edtCPFRESP.setText("");
        edtRGRESP.setText("");
        edtBairro.setText("");
        edtCompl.setText("");
    }

    private void carregadadoscl() {
        cl.setCODO_RAZAO(edtNome.getText());
        cl.setCODO_NOME(edtApelido.getText());
        if (rbFisico.isSelected())
            cl.setCODO_TIPO(0);
        else
            cl.setCODO_TIPO(1);
        cl.setCODO_ENDERECO(edtEnd.getText());
        cl.setCODO_NUM(edtNum.getText());
        //cl.setCODO_(edtCompl.getText());
        cl.setCODO_IBGE(edtIBGE.getText());
        cl.setCODO_CEP(edtCep.getText());
        cl.setCODO_TELEFONE(edtFone1.getText());
        cl.setCODO_RGRESPONSAVEL(edtRGRESP.getText());
        cl.setCODO_CPFRESPONSAVEL(edtCPFRESP.getText());
        cl.setCODO_EMAIL(edtEmail.getText());
        cl.setCODO_CONTATO(edtContato.getText());
        cl.setCODO_RESPONSAVEL(edtResp.getText());
        cl.setCODO_CNPJ(edtCPF.getText());
        cl.setCODO_IE(edtRG.getText());
        cl.setCODO_BAIRRO(edtBairro.getText());
        cl.setCODO_COMPLEMENTO(edtCompl.getText());
    }

    private void PreencheCampos() {
        //Ativa();
        lblCodCont.setText(String.valueOf(cl.getCODO_COD()));
        if (cl.getCODO_TIPO() == 1)
            rbFisicoActionPerformed(null);
        else
            rbJuridicoActionPerformed(null);
        edtNome.setText(cl.getCODO_RAZAO());
        edtApelido.setText(cl.getCODO_NOME());
        edtCPF.setText(cl.getCODO_CNPJ());
        edtRG.setText(cl.getCODO_IE());        
        edtEnd.setText(cl.getCODO_ENDERECO());
        edtNum.setText(cl.getCODO_NUM());
        edtCep.setText(cl.getCODO_CEP());
        edtFone1.setText(cl.getCODO_TELEFONE());
        edtEmail.setText(cl.getCODO_EMAIL());
        edtCPFRESP.setText(cl.getCODO_CPFRESPONSAVEL());
        edtRGRESP.setText(cl.getCODO_RGRESPONSAVEL());
        edtResp.setText(cl.getCODO_RESPONSAVEL());
        edtContato.setText(cl.getCODO_CONTATO());
        edtBairro.setText(cl.getCODO_BAIRRO());
        edtCompl.setText(cl.getCODO_COMPLEMENTO());
        edtIBGE.setText(cl.getCODO_IBGE());
        if (edtIBGE.getText() != "")
            PreencheIBGE();
    }

    private void PreencheIBGE() {
            IBGEBUS bus = new IBGEBUS();
            try 
            {
                clIBGE = bus.buscar(edtIBGE.getText());
                edtCidade.setText(clIBGE.getIBGE_CIDADE());
                edtUF.setText(clIBGE.getIBGE_UF());
            } catch (Exception ex) {
                Logger.getLogger(GUICadContratado.class.getName()).log(Level.SEVERE, null, ex);
            }
    }


}
